<?php

namespace app\service;


use app\model\UserBackpack;


//用户背包服务
class UserBackpackService extends BaseService
{

    public function add($user_id,$pid,$category,$type,$num): array
    {
        $user_backpack = new UserBackpack();
        $user_backpack->user_id = $user_id;
        $user_backpack->pid = $pid;
        $user_backpack->type = $type;
        $user_backpack->num = $num;
        $user_backpack->category = $category;
        $res = $user_backpack->save();
        if (empty($res)) {
            return $this->returnFail('数据库操作失败');
        }
        return $this->returnSuccess($user_backpack);
    }





}